<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <title>webXML配置详解  &middot; sitename</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">


<meta name="description" content="webXML配置详解 description" />

<meta name="keywords" content="one, two, ">


<meta property="og:title" content="webXML配置详解  &middot; sitename ">
<meta property="og:site_name" content="sitename"/>
<meta property="og:url" content="https://lvzongcheng.gitee.io/java/webxml%E9%85%8D%E7%BD%AE%E8%AF%A6%E8%A7%A3/" />
<meta property="og:locale" content="en-EN">


<meta property="og:type" content="article" />
<meta property="og:description" content="webXML配置详解 description"/>
<meta property="og:article:published_time" content="2017-05-13T00:00:00Z" />
<meta property="og:article:modified_time" content="2017-05-13T00:00:00Z" />

  
    
<meta property="og:article:tag" content="one">
    
<meta property="og:article:tag" content="two">
    
  

  

<script type="application/ld+json">
  {
    "@context": "http://schema.org",
    "@type": "Article",
    "headline": "webXML配置详解",
    "author": {
      "@type": "Person",
      "name": "LvZongCheng"
    },
    "datePublished": "2017-05-13",
    "description": "webXML配置详解 description",
    "wordCount":  81 
  }
</script>



<link rel="canonical" href="https://lvzongcheng.gitee.io/java/webxml%E9%85%8D%E7%BD%AE%E8%AF%A6%E8%A7%A3/" />

<link rel="apple-touch-icon-precomposed" sizes="144x144" href="https://lvzongcheng.gitee.io/touch-icon-144-precomposed.png">
<link href="https://lvzongcheng.gitee.io/favicon.png" rel="icon">

<meta name="generator" content="Hugo 0.60.0" />

  <!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->

<link href='https://fonts.googleapis.com/css?family=Merriweather:300%7CRaleway%7COpen+Sans' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="/css/font-awesome.min.css">
<link rel="stylesheet" href="/css/style.css">
<link rel="stylesheet" href="/css/highlight/default.css">

  
  
	<script>
	  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	  ga('create', 'Your Google Analytics tracking code', 'auto');
	  ga('send', 'pageview');

	</script>

</head>
<body>
  <main id="main-wrapper" class="container main_wrapper has-sidebar">
    <header id="main-header" class="container main_header">
  <div class="container brand">
  <div class="container title h1-like">
  <a class="baselink" href="https://lvzongcheng.gitee.io">
  LvZongCheng

</a>

</div>

  
<div class="container topline">
  
  淡定 执著 进取 自律


</div>


</div>

  <nav class="container nav primary no-print">
  

<a class="homelink" href="https://lvzongcheng.gitee.io">home</a>


  
<a href="https://lvzongcheng.gitee.io/framework" title="Show list of Frameworks">Frameworks</a>

<a href="https://lvzongcheng.gitee.io/java" title="Show list of Java">Java</a>

<a href="https://lvzongcheng.gitee.io/linux" title="Show list of Linux">Linux</a>

<a href="https://lvzongcheng.gitee.io/redis" title="Show list of Redis">Redis</a>

<a href="https://lvzongcheng.gitee.io/sql" title="Show list of SQL">SQL</a>

<a href="https://lvzongcheng.gitee.io/Spring" title="Show list of Spring">Spring</a>

<a href="https://lvzongcheng.gitee.io/tools" title="Show list of Tools">Tools</a>

<a href="https://lvzongcheng.gitee.io/webpage" title="Show list of WebPage">WebPage</a>

<a href="https://lvzongcheng.gitee.io/information" title="Show list of information">information</a>

<a href="https://lvzongcheng.gitee.io/network" title="Show list of network">network</a>

<a href="https://lvzongcheng.gitee.io/%E5%BE%AE%E6%9C%8D%E5%8A%A1" title="Show list of 微服务">微服务</a>

<a href="https://lvzongcheng.gitee.io/%E6%80%BB%E7%BB%93" title="Show list of 总结">总结</a>

<a href="https://lvzongcheng.gitee.io/%E6%9C%BA%E5%99%A8%E8%87%AA%E5%8A%A8%E5%8C%96" title="Show list of 机器自动化">机器自动化</a>

<a href="https://lvzongcheng.gitee.io/%E6%B1%87%E7%BC%96" title="Show list of 汇编">汇编</a>

<a href="https://lvzongcheng.gitee.io/%E8%AE%B0%E4%BA%8B%E6%9C%AC" title="Show list of 记事本">记事本</a>


</nav>

<div class="container nav secondary no-print">
  
<a id="contact-link-email" class="contact_link" rel="me" aria-label="Email" href="mailto:Lyc19880405@163.com">
  <span class="fa fa-envelope-square"></span></a>



<a id="contact-link-github" class="contact_link" rel="me" aria-label="Github" href="https://github.com/enten/hugo-boilerplate">
  <span class="fa fa-github-square"></span></a>




 


















</div>


  

</header>


<article id="main-content" class="container main_content single">
  <header class="container hat">
  <h1>webXML配置详解
</h1>

</header>

  <div class="container content">
  <div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-xml" data-lang="xml"><span style="color:#75715e">&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt;</span>
<span style="color:#f92672">&lt;web-app</span> <span style="color:#a6e22e">xmlns:xsi=</span><span style="color:#e6db74">&#34;http://www.w3.org/2001/XMLSchema-instance&#34;</span>
         <span style="color:#a6e22e">xmlns=</span><span style="color:#e6db74">&#34;http://java.sun.com/xml/ns/javaee&#34;</span>
          <span style="color:#a6e22e">xsi:schemaLocation=</span><span style="color:#e6db74">&#34;http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd&#34;</span> 
         <span style="color:#a6e22e">id=</span><span style="color:#e6db74">&#34;WebApp_ID&#34;</span> <span style="color:#a6e22e">version=</span><span style="color:#e6db74">&#34;3.0&#34;</span><span style="color:#f92672">&gt;</span>
         
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> icon元素指出IDE和GUI工具用来表示Web应用的一个和两个图像文件的位置。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;icon</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/icon&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> display</span><span style="color:#75715e">-</span><span style="color:#75715e">name元素提供GUI工具可能会用来标记这个特定的Web应用的一个名称。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;display-name</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/display-name&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> description元素给出与此有关的说明性文本。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;description</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/description&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> context</span><span style="color:#75715e">-</span><span style="color:#75715e">param元素声明应用范围内的初始化参数 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;context-param</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/context-param&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> filter 过滤器元素将一个名字与一个实现javax.servlet.Filter接口的类相关联。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;filter</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/filter&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> filter</span><span style="color:#75715e">-</span><span style="color:#75715e">mapping 一旦命名了一个过滤器，就要利用filter</span><span style="color:#75715e">-</span><span style="color:#75715e">mapping元素把它与一个或多个servlet或JSP页面相关联。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;filter-mapping</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/filter-mapping&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> listener 对事件监听程序的支持，事件监听程序在建立、修改和删除会话或servlet环境时得到通知。Listener元素指出事件监听程序类。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;listener</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/listener&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> servlet 在向servlet或JSP页面制定初始化参数或定制URL时，必须首先命名servlet或JSP页面。Servlet元素就是用来完成此项任务的。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;servlet</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/servlet&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> servlet</span><span style="color:#75715e">-</span><span style="color:#75715e">mapping 服务器一般为servlet提供一个缺省的URL：http://host/webAppPrefix/servlet/ServletName。但是，常常会更改这个URL，以便servlet可以访问初始化参数或更容易地处理相对URL。在更改缺省URL时，使用servlet</span><span style="color:#75715e">-</span><span style="color:#75715e">mapping元素。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;servlet-mapping</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/servlet-mapping&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> session</span><span style="color:#75715e">-</span><span style="color:#75715e">config 如果某个会话在一定时间内未被访问，服务器可以抛弃它以节省内存。可通过使用HttpSession的setMaxInactiveInterval方法明确设置单个会话对象的超时值，或者可利用session</span><span style="color:#75715e">-</span><span style="color:#75715e">config元素制定缺省超时值。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;session-config</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/session-config&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> mime</span><span style="color:#75715e">-</span><span style="color:#75715e">mapping 如果Web应用具有想到特殊的文件，希望能保证给他们分配特定的MIME类型，则mime</span><span style="color:#75715e">-</span><span style="color:#75715e">mapping元素提供这种保证。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;mime-mapping</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/mime-mapping&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> welcome</span><span style="color:#75715e">-</span><span style="color:#75715e">file</span><span style="color:#75715e">-</span><span style="color:#75715e">list元素指示服务器在收到引用一个目录名而不是文件名的URL时，使用哪个文件。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;welcome-file-list</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/welcome-file-list&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> error</span><span style="color:#75715e">-</span><span style="color:#75715e">page元素使得在返回特定HTTP状态代码时，或者特定类型的异常被抛出时，能够制定将要显示的页面。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;error-page</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/error-page&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> resource</span><span style="color:#75715e">-</span><span style="color:#75715e">env</span><span style="color:#75715e">-</span><span style="color:#75715e">ref元素声明与资源相关的一个管理对象。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;resource-env-ref</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/resource-env-ref&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> resource</span><span style="color:#75715e">-</span><span style="color:#75715e">ref元素声明一个资源工厂使用的外部资源。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;resource-ref</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/resource-ref&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> security</span><span style="color:#75715e">-</span><span style="color:#75715e">constraint元素制定应该保护的URL。它与login</span><span style="color:#75715e">-</span><span style="color:#75715e">config元素联合使用 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;security-constraint</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/security-constraint&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> 用login</span><span style="color:#75715e">-</span><span style="color:#75715e">config元素来指定服务器应该怎样给试图访问受保护页面的用户授权。它与sercurity</span><span style="color:#75715e">-</span><span style="color:#75715e">constraint元素联合使用。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;login-config</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/login-config&gt;</span>

    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> security</span><span style="color:#75715e">-</span><span style="color:#75715e">role元素给出安全角色的一个列表，这些角色将出现在servlet元素内的security</span><span style="color:#75715e">-</span><span style="color:#75715e">role</span><span style="color:#75715e">-</span><span style="color:#75715e">ref元素的role</span><span style="color:#75715e">-</span><span style="color:#75715e">name子元素中。分别地声明角色可使高级IDE处理安全信息更为容易。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;security-role</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/security-role&gt;</span>

    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> env</span><span style="color:#75715e">-</span><span style="color:#75715e">entry元素声明Web应用的环境项。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;env-entry</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/env-entry&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> ejb</span><span style="color:#75715e">-</span><span style="color:#75715e">ref元素声明一个EJB的主目录的引用。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;ejb-ref</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/ejb-ref&gt;</span>
    
    <span style="color:#75715e">&lt;!--</span><span style="color:#75715e"> ejb</span><span style="color:#75715e">-</span><span style="color:#75715e">local</span><span style="color:#75715e">-</span><span style="color:#75715e">ref元素声明一个EJB的本地主目录的应用。 </span><span style="color:#75715e">--&gt;</span>
    <span style="color:#f92672">&lt;ejb-local-ref</span><span style="color:#f92672">&gt;</span><span style="color:#f92672">&lt;/ejb-local-ref&gt;</span>

<span style="color:#f92672">&lt;/web-app&gt;</span>
</code></pre></div>
</div>


  
</article>
      <footer id="main-footer" class="container main_footer">
  

  <div class="container nav foot no-print">
  
<a href="https://lvzongcheng.gitee.io/license">license</a>


  <a class="toplink" href="#">back to top</a>

</div>

  <div class="container credits">
  
<div class="container footline">
  
  code with <!-- raw HTML omitted --><!-- raw HTML omitted -->


</div>


  
<div class="container copyright">
  
  (c) 2015 yourname.


</div>


</div>

</footer>

    </main>
    
<script type="text/javascript">
  (function() {
    
    
    if (window.location.hostname == "localhost")
      return;
    var dsq = document.createElement('script'); dsq.async = true; dsq.type = 'text/javascript';
    dsq.src = '//your_disqus_shortname.disqus.com/count.js';
    (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
  })();
</script>



<script src="/js/highlight.pack.js"></script>
<script>hljs.initHighlightingOnLoad();</script>



    
  </body>
</html>

